import { Dispatcher } from "../../../mvc/core/Dispatcher";
import { EventName } from "../../mvc/EventName";
import { ObjCreate } from "../common/ObjCreate";
import { Language } from "../../../../extend/language/Language";
import { NumInput } from "../common/NumInput";
import { SystemSetter } from "./SystemSetter";
import { DataEvent } from "../../events/DataEvent";
import { EffectManager } from "../../manager/EffectManager";
import { GCheckBox } from "../../../../com/mui/controls/GCheckBox";
import { LineBox } from "../guide/LineBox";
type int = number;
//class PlayerNumItem
    
    export  class PlayerNumItem /* flash.display.Sprite */
    {
        constructor()
        {
            
            this.init();
            Dispatcher.addEventListener(EventName.Guide_PlayerNumSet, this.onGuidePlayerNumSetHandler);
            return;
        }

        /* internal  */init(): void
        {
            this._numCb = ObjCreate.createCheckBox(Language.getString(33024), 0, 0, 180, 25, this);
            this._numCb.addEventListener(flash.events.Event.CHANGE, this.onNumCbChangeHandler);
            this._numInput = new NumInput();
            this._numInput.minNum = 0;
            this._numInput.maxNum = 999;
            this._numInput.currentNum = 50;
            this._numInput.x = 20;
            this._numInput.y = 25;
            this._numInput.addEventListener(flash.events.Event.CHANGE, this.onPlayerNumChangeHandler);
            addChild(this._numInput);
            return;
        }

        /* internal  */onNumCbChangeHandler(arg1: Object /* flash.events.Event */): void
        {
            SystemSetter.localSetter.isAlter = true;
            SystemSetter.localSetter.playerOnScreen = this._numCb.selected;
            return;
        }

        /* internal  */onPlayerNumChangeHandler(arg1: Object /* flash.events.Event */): void
        {
            SystemSetter.localSetter.isAlter = true;
            return;
        }

        public get playerNum(): int
        {
            return this._numInput.currentNum;
        }

        public set playerNum(arg1: int)
        {
            this._numInput.currentNum = arg1;
            this._numCb.selected = SystemSetter.localSetter.playerOnScreen;
            return;
        }

        /* internal  */onGuidePlayerNumSetHandler(arg1: DataEvent): void
        {
            if (this._lineBox == null) 
            {
                this._lineBox = EffectManager.getLineBox(100, 25);
                this._lineBox.x = 13;
                this._lineBox.y = 20;
            }
            if (!this.contains(this._lineBox)) 
            {
                this.addChild(this._lineBox);
            }
            if (this._timer == null) 
            {
                this._timer = new Object /* flash.utils.Timer */(1000);
                this._timer.repeatCount = 10;
                this._timer.addEventListener(flash.events.TimerEvent.TIMER_COMPLETE, this.onTimerCompleteHandler);
            }
            this._timer.reset();
            this._timer.start();
            return;
        }

        /* internal  */onTimerCompleteHandler(arg1: Object /* flash.events.TimerEvent */): void
        {
            if (this._timer) 
            {
                this._timer.stop();
            }
            if (this._lineBox && this.contains(this._lineBox)) 
            {
                this.removeChild(this._lineBox);
            }
            return;
        }

        /* internal */ /* var */_numCb: GCheckBox;

        /* internal */ /* var */_numInput: NumInput;

        /* internal */ /* var */_timer: Object /* flash.utils.Timer */;

        /* internal */ /* var */_lineBox: LineBox;
    }
